package com.haidechizi.i18n.common.utils;

import com.haidechizi.i18n.common.support.I18nReflectUtils;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @author dejun.wang
 * @date 2021/12/13
 */
public class CacheUtils {

    public static String[] generateKeys(String systemCode, String businessCode, String languageName,
                                        List<String> businessKeyList) {
        Set<String> keys = businessKeyList.stream().map(businessKey -> {
            return generateKey(systemCode, businessCode, languageName, businessKey);
        }).collect(Collectors.toSet());
        return keys.toArray(new String[0]);
    }

    public static String generateKey(String systemCode, String businessCode, String languageName, String businessKey) {
        StringBuilder sb = new StringBuilder();
        sb.append(systemCode).append(":")
                .append(businessCode).append(":")
                .append(languageName).append(":")
                .append(businessKey);
        return sb.toString();
    }
}
